class Solution
{
public:
    vector<vector<string>> mostPopularCreator(vector<string> &creators, vector<string> &ids, vector<int> &views)
    {
        unordered_map<string, pair<long long, vector<int>>> creatorInfo;
        int n = creators.size();
        for (int i = 0; i < n; ++i)
        {
            creatorInfo[creators[i]].first += views[i];
            creatorInfo[creators[i]].second.push_back(i);
        }
        long long maxView = -1;
        vector<string> maxCreators;
        for (auto &[creator, info] : creatorInfo)
        {
            if (info.first > maxView)
            {
                maxCreators.clear();
                maxCreators.push_back(creator);
                maxView = info.first;
            }
            else if (info.first == maxView)
            {
                maxCreators.push_back(creator);
            }
        }
        vector<vector<string>> result;
        for (auto &maxCreator : maxCreators)
        {
            string maxViewVideo = "zzzzzzz";
            long long maxVideoViewCount = -1;
            for (int index : creatorInfo[maxCreator].second)
            {
                if (views[index] > maxVideoViewCount)
                {
                    maxVideoViewCount = views[index];
                    maxViewVideo = ids[index];
                }
                else if (views[index] == maxVideoViewCount)
                {
                    if (ids[index] < maxViewVideo)
                    {
                        maxViewVideo = ids[index];
                    }
                }
            }
            result.push_back({maxCreator, maxViewVideo});
        }

        return result;
    }
};